package cn.tansanqinger.dao.sql.file;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.tansanqinger.dao.sql.IFileNameSqlDao;
import cn.tansanqinger.pojo.Filename;

@Repository
public class FileNameSqlDaoImpl {

	@Autowired
	private IFileNameSqlDao dao;
	
	/**
	 * 根据条件查询
	 * @param uid
	 * @return
	 */
	public List<Filename> selectAll(int uid) {
		QueryWrapper<Filename> queryWrapper = new QueryWrapper<Filename>();
		queryWrapper.lambda().eq(Filename::getUid, uid);
		return dao.selectList(queryWrapper);
	}
	
	/**
	 * 根据主键查询数据
	 * @param 
	 * @return
	 */
	public Filename selectFidOne(int id) {
		return dao.selectById(id);
	}
	
	/**
	 * 添加数据
	 * @param 
	 * @return
	 */
	public int add(Filename filename) {
		dao.insert(filename);
		return filename.getFid();
	}
	
	/**
	 * 修改数据
	 * @param 
	 * @return
	 */
	public int modification(Filename filename) {
		return dao.updateById(filename);
	}
	
	/**
	 * 删除数据
	 * @param id
	 * @return
	 */
	public int delete(int id) {
		return dao.deleteById(id);
	}
}
